﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Divisions : System.Web.UI.Page
{
    string path = "";
    bool company = false;
    bool student = false;

    protected void Page_Load(object sender, EventArgs e)
    {
        path = HttpContext.Current.Request.Url.AbsoluteUri;
        DivisionBLL dBll = new DivisionBLL();
        //btnBusiness.DataSource = dBll.GetDivisionByID(2);
        

        if (path.EndsWith("1"))
        {
            company = true;
        }
        else if (path.EndsWith("2"))
        {
            student = true;
        }
        else
        {
            lblStatus.Text = "Der er intet her nu?";
        }



    }

    private void RedirecterCreate(object argument)
    {
        if (company)
        {
            Response.Redirect("~/CreateProject.aspx?1/" + argument);
        }
        else if (student)
        {
            Response.Redirect("~/CreateProject.aspx?2/" + argument);
        }
    }
    private void RedirecterFind(object argument)
    {
        if (company)
        {
            Response.Redirect("~/FindProject.aspx?1/" + argument);
        }
        else if (student)
        {
            Response.Redirect("~/FindProject.aspx?2/" + argument);
        }
    }

    protected void btnBuisness_Click(object sender, ImageClickEventArgs e)
    {
        hfArgument.Value = btnBusiness.CommandArgument;
        mvDivisions.ActiveViewIndex = 1;
    }
    protected void btnPedagogue_Click(object sender, ImageClickEventArgs e)
    {
        hfArgument.Value = btnPedagogue.CommandArgument;
        mvDivisions.ActiveViewIndex = 1;
    }
    protected void btnInterdisciplinary_Click(object sender, ImageClickEventArgs e)
    {
        hfArgument.Value = btnInterdisciplinary.CommandArgument;
        mvDivisions.ActiveViewIndex = 1;
    }
    protected void btnHealthEducation_Click(object sender, ImageClickEventArgs e)
    {
        hfArgument.Value = btnHealthEducation.CommandArgument;
        mvDivisions.ActiveViewIndex = 1;
    }
    protected void btnTechnology_Click(object sender, ImageClickEventArgs e)
    {
        hfArgument.Value = btnTechnology.CommandArgument;
        mvDivisions.ActiveViewIndex = 1;
    }
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        RedirecterCreate(hfArgument.Value);
    }
    protected void btnFind_Click(object sender, EventArgs e)
    {
        RedirecterFind(hfArgument.Value);
    }

    protected void lbtnBusiness_Click(object sender, EventArgs e)
    {
        string text = "hej";
        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + text + "');", true);
    }
    protected void btnFrontPage_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Default.aspx");
    }
    protected void btnGoBack_Click(object sender, EventArgs e)
    {
        mvDivisions.ActiveViewIndex = 0;
    }
}